<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body style="height:3000px">
  <div id="app">
    <button @click="isShow = !isShow">消失</button>
    <keep-alive>
      <home v-if="isShow"></home>
    </keep-alive>
  </div>
  <script src="./vue.js"></script>
  <script>
    const Home = {
      template:`
        <div>
          home组件
          <input v-model="msg"/>
        </div>
      `,
      data () {
        return {
          msg:""
        }
      },
      activated(){
        console.log('我又激活了')
      },
      deactivated() {
        console.log('我又休眠了')
      },
      beforeCreate() {
        console.log('实例创建完成之前')
      },
      created(){
        console.log('实例创建完成，组件的属性和方法已经可以调用，且数据已经变成响应式了')
      },
      beforeMount(){
        console.log('组件模板渲染之前')
      },
      mounted() {
        console.log('组件模板渲染完成')
       
      },
      beforeUpdate() {
        console.log('组件更新之前')
      },
      updated() {
        console.log('组件更新完成，可以获取最新dom了')
       
      },
      beforeDestroy() {
        console.log('组件销毁之前')
        
      },
      destroyed() {
        console.log('组件已经销毁')
      }
    }
    Vue.component('Home', Home)
    const vm = new Vue({
      el: '#app',
      data:{
        isShow: true
      }
    })
  </script>
</body>
</html>